<template>
  <div class="app-container">
    <el-input v-model="listQuery.code" class="filter-item" placeholder="礼包码" style="width: 120px;"></el-input>
    <el-button class="filter-item" type="primary" plain icon="el-icon-search" @click="handleFilter">搜索</el-button>
    <el-table v-loading="listLoading" :data="list" class="mt-15" height="660" border>
      <el-table-column label="礼包码" prop="code" width="100px" align="center"></el-table-column>
      <el-table-column label="礼包名称" prop="gift_name" width="90px" align="center"></el-table-column>
      <el-table-column label="礼包内容" prop="items_str" width="550px" align="center"></el-table-column>
      <el-table-column label="类型" width="70px" align="center">
        <template slot-scope="{row}">
          <span v-if="row.type === 1">普通码</span>
          <span v-else>指定码</span>
        </template>
      </el-table-column>
      <el-table-column label="使用时间" prop="create_dt" width="140px" align="center"></el-table-column>
      <el-table-column label="角色ID" prop="actor_id" width="110px" align="center"></el-table-column>
      <el-table-column label="角色名" prop="actor_name" width="110px" align="center"></el-table-column>
      <el-table-column label="等级" prop="level" width="60px" align="center"></el-table-column>
      <el-table-column label="VIP" prop="vip" width="60px" align="center"></el-table-column>
      <el-table-column label="充值金额" prop="amount" width="80px" align="center"></el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
  </div>
</template>
<script>
import { getGiftCodeLogList } from '@/api/operator'
import Pagination from '@/components/Pagination'

export default {
  name: 'GiftList',
  components: { Pagination },
  data() {
    return {
      listLoading: false,
      listQuery: {
        code: '',
        page: 1,
        limit: 200
      },
      total: 0,
      list: []
    }
  },
  computed: {
  },
  created() {
    this.getList()
  },
  methods: {
    async getList() {
      this.listLoading = true
      getGiftCodeLogList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        this.listLoading = false
      })
    },
    handleFilter() {
      this.getList()
    }
  }
}
</script>

